package com.activenetwork.util.grid.condition;

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class EqualCondition implements Condition {
	
    private int column;
    private String value;
    
    public void setColumn(int column) {
		this.column = column;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public int getColumn() {
	    return column;
	}
    public String getValue() {
        return value;
    }
    /**
     * Empty constructor
     */
    public EqualCondition(){
    	this.column = -1;
    	this.value = null;
    }
    /**
     * Direct constructor
     * @param column
     * @param value
     */
    public EqualCondition(int column, String value) {
        this.column = column;
        this.value = value;
    }
    
    @Override
    public boolean matchs(WebElement row) {
        boolean flag = false;
        if (StringUtils.equalsIgnoreCase(value, row.findElement(By.xpath("./td[" + column + "]")).getText().trim())) {
            flag = true;
        }
        return flag;
    }
}
